package com.tgy.programmer_code_interview_guide._03_binarytree;


class BinaryGeneral{

    public static int general(int n) {

        if (n < 1) {
            return 1;
        }

        int[] nums = new int[n+1];
        nums[0] = 1;
        for (int i = 1; i < nums.length; i++) {

            int sum = 0;
            for (int j = 1; j <= i; j++) {

                sum += (nums[j - 1] * nums[i - j]);
            }

            nums[i] = sum;
        }

        return nums[n];
    }

}

public class _23_统计生成的二叉树 {

    public static void main(String[] args) {
        System.out.println(BinaryGeneral.general(3));
    }
}
